package unit7;

import java.util.Scanner;

public class Test5 {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true) {
			System.out.println("请输入八位数，【8个0表示结束】：");
			String LuckyNum=scanner.next();
			if ("00000000".equals(LuckyNum)) {
				System.out.println("再见，欢迎下次光临");
				break;
			}else {
				if (LuckyNum.length()==8) {
					boolean flag=true;
					for(int i=0;i<LuckyNum.length()-1;i++) {
						char a=LuckyNum.charAt(i);
						if (a<'0'||a>'9') {
							System.out.println("输入非法字母，请重新输入！");
							flag=false;
							break;
						}
					}
					if (flag) {
						if (LuckyNum.charAt(0)=='0') {
							System.out.println("最高位是0，请重新输入");
							continue;
						}else {
							long luckNum=Long.parseLong(LuckyNum);
							int sum=0;
							do {
								sum+=luckNum%10;
								luckNum/=10;
							} while (luckNum!=0);
							if (sum%7==0) {
								System.out.println("中奖！");
							}else {
								System.out.println("未中奖！");
							}
						}
					}
				}else {
					System.out.println("您输入的不是八位数，请继续输入！");
				}
			}
		}

	}

}
